var  urls=["https://jira.foxitsoftware.cn/secure/Dashboard.jspa?selectPageId=16038&os_username=xiuju_lan&os_password=Test,123",
    "https://jira.foxitsoftware.cn/secure/Dashboard.jspa?selectPageId=16037&os_username=xiuju_lan&os_password=Test,123",
    "https://jira.foxitsoftware.cn/secure/Dashboard.jspa?selectPageId=16039&os_username=xiuju_lan&os_password=Test,123",
    "https://jira.foxitsoftware.cn/secure/Dashboard.jspa?selectPageId=16040&os_username=xiuju_lan&os_password=Test,123"];
var names=["CPDF-Q4" , "CVAS-Q4","CBASE-Q4","COPS-Q4"];
var webPage = require('webpage');
function promise1 (urls,names) {
    var i = urls.length;
	console.log(i);
	if (!i) {
		return phantom.exit();
	}
    var url = urls.pop();
	var name = names.pop();
    var page = require('webpage').create();
  //  page.viewportSize = { width: 800, height: 600 };
	console.log('start', url);
    console.log('pngName:', name);
    page.open(url, function(status) {
        console.log("Status ***** " + status);
     //   
		 window.setTimeout(function () {
		      page.evaluate(function() {
	 var today = new Date();
     var text = window.document.getElementsByClassName("aui-page-header-main")[0].children[0].textContent;
     window.document.getElementsByClassName("aui-page-header-main")[0].children[0].innerText=text+" "+today
    });
	
          var pageSize = document.getElementsByTagName('html')[0].getBoundingClientRect();
		  console.log("pageSize.width:" + pageSize.width);
		   console.log("pageSize.height:" + pageSize.height);
		   
	      page.viewportSize = {width: pageSize.width, height: pageSize.height};
            page.render(name+".png");
			 page.render(name+".pdf");
            console.log("render file ***** ");
			promise1(urls,names);
}, 20000 );
    });
}
promise1(urls,names);